package org.example.dao.dto.post;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.dao.entity.post.PComment;
import org.example.dao.entity.post.PPost;
import org.example.dao.entity.post.PReply;

/**
 * @author 22449
 * 存入redis中的post信息
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PostRedisDto {

    private String likeNum;
    private String browseNum;
    private String clickNum;

    private String transmitNum;

    public PostRedisDto(PReply pReply){
        this.likeNum = pReply.getLikeNum().toString();
    }

    public PostRedisDto(PComment comment){
        this.likeNum = comment.getLikeNum().toString();
    }

    public PostRedisDto(PPost post){
        this.likeNum = post.getLikeNum().toString();
        this.browseNum = post.getBrowseNum().toString();
        this.clickNum = post.getClickNum().toString();
        this.transmitNum = post.getTransmitNum().toString();
    }

    public PPost setCacheData(PPost post){
       post.setClickNum(Integer.valueOf(clickNum));
       post.setLikeNum(Integer.valueOf(likeNum));
       post.setTransmitNum(Integer.valueOf(transmitNum));
       post.setBrowseNum(Integer.valueOf(browseNum));
       return post;
    }

    public PComment setCacheData(PComment post){
        post.setLikeNum(Integer.valueOf(likeNum));
        return post;
    }

}

